<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" type="text/css" href="../css/reset.css">
    <link rel="stylesheet" type="text/css" href="../css/entry.css">
    <script type="text/javascript" src='../js/adaptive.js'></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/1.8.0/jquery-1.8.0.js"></script>
    <title>报名</title>
</head>
<body>
   <div class="entryWrap">
        <img src="../images/secondText.png" alt="" class="entrtText">
        <div class="formContent">
            <form action="" class="form" method="POST">
                <div class="formItem ">
                        <span>姓名:</span>
                        <input class="formItemtypes formItemName" placeholder="请输入姓名">
                </div>
                <div class="formItem ">
                        <span>电话:</span>
                        <input class="formItemtypes formItemTel" placeholder="请输入电话">
                </div>
                 <div class="formItem formItemGroup">
                        <span>所属:</span>
                       <div class= "formItemtypes button custom-select">
                            <select name="" id="select">
                                <option value="请选择">请选择</option>
                                <option value="选择2">选择2</option>
                                <option value="选择3">选择3</option>
                                <option value="选择4">选择4</option>
                            </select>
                        </div>
                </div>
            </form>
        </div>
         <p class="startBtn">
            <a >
                    闯关入口
            </a>
    </p>
   </div>
   <script>
       $('.startBtn a').click(function(){
           var name = $('.formItemName').val()
           var tel =$('.formItemTel').val()
           var select=$('#select').val()
           var pattern = /^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$/;
           var patternName =/[\u4E00-\u9FA5]{2,5}(?:·[\u4E00-\u9FA5]{2,5})*/
           if(!name||!tel||!select){
               alert('请完善您的信息')
               return false
           }
           if(!pattern.test(tel)){
               alert('手机号码填写错误')
               return false
           }
           if(!patternName.test(name)){
               alert('请输入正确的姓名')
               return false
           }
           if(select=='请选择'){
                alert('请选择您的所属')
               return false
           }
           setCookie('name',name)
           setCookie('tel',tel)
           setCookie('select',select)
           window.location ='question.html'
       })
        function setCookie(c_name,value,expiredays){
            var exdate=new Date()
            exdate.setDate(exdate.getDate()+expiredays)
            document.cookie=c_name+ "=" +escape(value)+
            ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
		 }

		 //取回cookie
		 function getCookie(c_name) {
		 if (document.cookie.length>0){
		   c_start=document.cookie.indexOf(c_name + "=")
		   if (c_start!=-1)
		     { 
		     c_start=c_start + c_name.length+1 
		     c_end=document.cookie.indexOf(";",c_start)
		     if (c_end==-1) c_end=document.cookie.length
		     return unescape(document.cookie.substring(c_start,c_end))
		     } 
		   }
		 return ""
		 }
   </script>
</body>
</html>